home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (DO) / Nibble Volume 09, No. 07 (1988-07)(MicroSPARC)(Side B).zip / Nibble Volume 09, No. 07 (1988-07)(MicroSPARC)(Side B).do / SWAT.MOUSE.S < prev    next >
Text File  |  1996-12-24  |  6KB  |  8 lines

  1.                         ;2**************************************************2*                                                *2*                   SWAT.MOUSE                   *2*                                                *2*             by S. Scott Zimmerman              *2*              Copyright (c) 1988                *2*              by MicroSPARC, Inc                *2*              Concord, MA  01742                *2*                                                *2*            The MicroSPARC Assembler            *2*                                                *2**************************************************  ORG $8000 ;Decimal 32768 2**************************************************2*  EQUates:                                      *2************************************************** FLINDX EQU $00 ;Fly index$XSWAT EQU $02 ;X position of swatter$YSWAT EQU $03 ;Y position of swatter XINPUT EQU $04 ;X position input YINPUT EQU $05 ;Y position input"NFLIES EQU $06 ;Current # of fliesDELAY EQU $C0 ;Delay constant 2**************************************************2*  Low-Resolution Graphics Routines:             *2************************************************** $PLOT EQU $F800 ;Plot a low-res point#SETCOL EQU $F864 ;Set low-res color#SCRN EQU $F871 ;Get color on screen%SETGR EQU $FB40 ;Set low-res graphics 2**************************************************2*  Mouse Addresses/Routines (Assume slot 4!):    *2************************************************** &SMOFF EQU $C412 ;Set mouse mode offset"RMOFF EQU $C414 ;Read mouse offset(IMOFF EQU $C419 ;Initialize mouse offset#XLO EQU $47C ;Low byte of abs X pos$XHI EQU $57C ;High byte of abs X pos#YLO EQU $4FC ;Low byte of abs Y pos$YHI EQU $5FC ;High byte of abs Y posBUTTON EQU $77C ;Button status 2**************************************************2*  Other Monitor Routines:                       *2************************************************** (SPEAKER EQU $C030 ;Apple speaker address%GIVAYF EQU $E2F2 ;Floats A,Y into FAC#SNGFLT EQU $E301 ;Float single byte(CONINT EQU $E6FB ;Convert FAC to integer!FMULTT EQU $E982 ;Mult FAC by ARG$CONUPK EQU $E9E3 ;Move memory to ARGMUL10 EQU $EA39 ;Mult FAC by 10&RND EQU $EFAE ;Random number generatorSETTXT EQU $FB39 ;Set text mode!HOME EQU $FC58 ;Clear text screen$WAIT EQU $FCA8 ;Monitor wait (delay) 2**************************************************2*  Program MAIN and MAINLOOP                     *2************************************************** ! JSR SETUP ;Prepare to start game JSR GOODTONE ;Sound tone 'MAINLOOP JSR GETXY ;Get X,Y coordinates JSR MOVESWAT ;Move swatter JSR CHECKHIT ;Check if hit fly JSR MOVFLIES ;Move flies LDA #DELAY ;Pause here...  JSR WAIT ;...using monitor wait LDA NFLIES ;All flies gone? BPL MAINLOOP ;No, go again JSR GOODTONE ;Yes, sound tone JSR SETTXT ;Set text mode JSR HOME ;Clear screen JMP $3D0 ;Warmstart Applesoft 2**************************************************2*  SUBROUTINES:                                  *2************************************************** &SETUP JSR SETGR ;Init low-res graphics JSR HOME ;Clear text window JSR SETFLIES ;Draw init flies  JSR INITVALS ;Initialize values2*================= Mouse setup ==================* LDA SMOFF ;Get offset byte STA SETMOUSE+1
  2.  LDA RMOFF STA READMOUSE+1
  3.  LDA IMOFF STA INITMOUSE+1$ JSR INITMOUSE ;Start the mouse card LDA #1 ;Set to passive mode! JSR SETMOUSE ;Set the mouse mode2*================================================* JSR GETXY ;Get initial X,Y  JSR COPYXY ;Copy input to value JSR PUTSWAT ;Put swat there RTS ;End of SETUP $SETFLIES LDA #12 ;Set color to green  JSR SETCOL LDX #9 ;Set for 10 flies#SFLOOP STX FLINDX ;Save index value$AGAIN JSR RNDINT ;Get randon integer LDX FLINDX ;Restore X index  STA XFLY,X ;Save X value of fly JSR RNDINT ;Get random integer LDX FLINDX ;Restore X index  STA YFLY,X ;Save Y value of fly LDY XFLY,X ;Set A,Y for SCRN JSR SCRN ;Get color there TAY ;Is it zero? BNE AGAIN ;No, so go again LDA YFLY,X ;Get coords back  LDY XFLY,X JSR PLOT ;Plot point LDX FLINDX ;Get index DEX ;Go to next fly  BPL SFLOOP ;Go agin if not done RTS ;End of SETFLIES %INITVALS LDX #9 ;Set num - 1 of flies STX NFLIES ; to ten LDA #1 ;Initialize fly flags'IVLOOP STA FLFLAG,X ;Zero the fly flags DEX ;End of loop? BPL IVLOOP ;No, go again RTS HITTONE LDA #80 ;Get pitch LDX #10 ;Get duration BNE TONE ;Aways branchGOODTONE LDA #30 ;Get pitch LDX #80 ;Get durationTONE TAY ;Save pitch'TONELOOP BIT SPEAKER ;Click the speaker TYA ;Get pitch (delay) JSR WAIT ;Pause here DEX ;Decrement duration% BNE TONELOOP ;Loop if pitch not done RTS 2*================= Mouse GETXY ==================*#GETXY JSR READMOUSE ;Read the mouse LDY XLO ;Get X value LDA XHI JSR GIVAYF ;Float it into FAC$ LDA #FSCALE ;Multiplier for scaling
  4.           LDY #FSCALE/ JSR CONUPK ;Move to ARG JSR FMULTT ;Mult X by scale JSR CONINT ;Take integral part STX XINPUT ;Save as X input LDY YLO ;Get Y value LDA YHI JSR GIVAYF ;Float it into FAC$ LDA #FSCALE ;Multiplier for scaling
  5.           LDY #FSCALE/ JSR CONUPK ;Move to ARG JSR FMULTT ;Mult Y by scale JSR CONINT ;Take integral part STX YINPUT ;Save as Y input RTS2*================================================* $COPYXY LDA XINPUT ;Get current input STA XSWAT ;Save as swat X LDA YINPUT ;Get current input STA YSWAT ;Save as swat Y RTS #PUTSWAT LDA #15 ;Set color to white! JSR SETCOL ;Go set low-res color LDA YSWAT ;Get coordinates
  6.  LDY XSWAT JMP PLOT ;Plot swat on screen #MOVESWAT LDA #0 ;Set color to black JSR SETCOL ; for erasing BIT BUTTON ;Don't move if a BMI MSEXIT ; button is down LDA YSWAT ;Get coordinates CMP YINPUT ;Is it different? BNE ERASEIT ;Yes, go erase it
  7.  LDY XSWAT CPY XINPUT ;Is it different BNE ERASEIT ;Yes, erase itMSEXIT RTS ;No need to move it'ERASEIT LDY XSWAT ;Make sure X in Y-reg JSR PLOT ;Erase swat JSR COPYXY ;Put new in current JMP PUTSWAT ;Go plot new %CHECKHIT LDX #9 ;Check flies for hits$CHLOOP LDA FLFLAG,X ;Is this fly on?! BEQ CHEND ;No, go to end of loop LDA XFLY,X ;Get fly X value CMP XSWAT ;Location of swat?! BNE CHEND ;No, go to end of loop LDA YFLY,X ;Get fly Y value CMP YSWAT ;Location of swat?! BNE CHEND ;No, go to end of loop BIT BUTTON ;Is button on? BMI HIT ;Yes, it's a hit RTS ;No, so just quitHIT LDA #0 ;Zero this flag
  8.